#include "swpsimactivityconnectorgraphicitem.h"

#include "graphicitemcommon.h"

using namespace core;
using namespace swp;

SwpSimActivityConnectorGraphicItem::SwpSimActivityConnectorGraphicItem(
    QGraphicsItem* parent) : SwpActivityConnectorGraphicItem(parent),
    ISimItem(),
    m_isInSimPath(false),
    m_originId()
{
    setFlag(QGraphicsItem::ItemIsMovable, false);

    setHandlesMovable(false);

    updateLine();
}

SwpSimActivityConnectorGraphicItem::SwpSimActivityConnectorGraphicItem(
    SwpActivityConnectorGraphicItem* from,
    QGraphicsItem* parent) : SwpActivityConnectorGraphicItem(
        from->startPoint(),
        from->endPoint(),
        from->anchors(),
        parent), ISimItem(),
        m_isInSimPath(false),
        m_originId(from->id())
{
    setFlag(QGraphicsItem::ItemIsMovable, false);

    setHandlesMovable(false);

    updateLine();
}

SwpSimActivityConnectorGraphicItem::~SwpSimActivityConnectorGraphicItem()
{

}

int SwpSimActivityConnectorGraphicItem::type() const
{
    return SWP_SIM_ACTIVITY_CONNECTOR_ITEM;
}

IEditorItem* SwpSimActivityConnectorGraphicItem::copy() const
{
    return new SwpSimActivityConnectorGraphicItem();
}

bool SwpSimActivityConnectorGraphicItem::isInSimPath() const
{
    return m_isInSimPath;
}

void SwpSimActivityConnectorGraphicItem::setInSimPath(bool in)
{
    QBrush brush(in ? m_palette->acceptsConnectionColor().darker(125) :
        m_palette->borderColor());
    setBrush(brush);

    if (m_startArrow != 0 )
    {
        m_startArrow->setBrush(brush);
    }

    if (m_endArrow != 0 )
    {
        m_endArrow->setBrush(brush);
    }

    m_isInSimPath = in;
}

QUuid SwpSimActivityConnectorGraphicItem::originId() const
{
    return m_originId;
}
